package cate.game.role.show.frame;


import cate.common.table.d.GDBlog;
import cate.game.role.show.ShowBagTab;
import cate.game.role.show.msg.ModifyHeadFrameResp;
import easy.java.dev.note.NoteClass;

import java.util.List;


@NoteClass("头像框")
public class RoleHeadFrame extends ShowBagTab<HeadFrame> {


    @Override
    public byte getType() {
        return GDBlog.DecorateType.HEAD_FRAME;
    }

    @Override
    protected HeadFrame createItem(int tid, long validTime) {
        return new HeadFrame(tid,validTime);
    }


    @Override
    public void onCreate() {
        // 送一个默认的头像框
        HeadFrame headFrame = new HeadFrame(GDBlog.DEFAULT_HEAD_FRAME, -1);
        list.add(headFrame);
        role.getBase().headFrame.tid = headFrame.tid;
    }

    @Override
    public void onInvalid(List<Integer> expireTids) {
        for (Integer expireTid : expireTids) {
            if (role.getBase().headFrame.tid == expireTid) {
                role.getBase().headFrame.tid = GDBlog.DEFAULT_HEAD_FRAME;
                role.getBase().headFrame.level = 1;
                role.sendNow(new ModifyHeadFrameResp(role));
                return;
            }
        }
    }


}
